<!DOCTYPE html>












  


<html class="theme-next gemini use-motion" lang="zh-CN">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">












<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">






















<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.7.0" rel="stylesheet" type="text/css">

<link href="/blog/css/main.css?v=6.4.2" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=6.4.2">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png?v=6.4.2">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png?v=6.4.2">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=6.4.2" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Gemini',
    version: '6.4.2',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="redis服务不可用，可能是磁盘和cpu问题导致，端口和服务是正常的，但是访问不了">
<meta name="keywords" content="故障排除">
<meta property="og:type" content="article">
<meta property="og:title" content="Docker 容器日志清理">
<meta property="og:url" content="https://xit-edu.cn/2024/10/19/blog/fault-docker-log/fault-docker-log/index.html">
<meta property="og:site_name" content="厦门工学院">
<meta property="og:description" content="redis服务不可用，可能是磁盘和cpu问题导致，端口和服务是正常的，但是访问不了">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2024-10-19T14:51:43.139Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Docker 容器日志清理">
<meta name="twitter:description" content="redis服务不可用，可能是磁盘和cpu问题导致，端口和服务是正常的，但是访问不了">






  <link rel="canonical" href="https://xit-edu.cn/2024/10/19/blog/fault-docker-log/fault-docker-log/">



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>Docker 容器日志清理 | 厦门工学院</title>
  






  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?d3f181d3d99fc3c240567d5b682eebd1";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>






  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">厦门工学院</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <p class="site-subtitle">软件研发工作室</p>
      
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/blog/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/blog/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">
    <a href="/blog/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-categories">
    <a href="/blog/categories/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-works1">
    <a href="/blog/works1/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-sitemap"></i> <br>H5小游戏1</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-works2">
    <a href="/blog/works2/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-calendar"></i> <br>H5小游戏2</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-fiction">
    <a href="/blog/fiction/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br>大将军归来</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-about">
    <a href="/blog/about/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-user"></i> <br>关于</a>
  </li>

      
      
    </ul>
  

  

  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
            

          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://xit-edu.cn/blog/2024/10/19/blog/fault-docker-log/fault-docker-log/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="对美好事物的向往，心中要充满强烈的愿望！">
      <meta itemprop="description" content="沉淀下来的知识，才是真正的财富！">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="厦门工学院">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Docker 容器日志清理
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2024-10-19 12:00:00 / 修改时间：22:51:43" itemprop="dateCreated datePublished" datetime="2024-10-19T12:00:00+08:00">2024-10-19</time>
            

            
              

              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/blog/categories/故障排除/" itemprop="url" rel="index"><span itemprop="name">故障排除</span></a></span>

                
                
                  ，
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/blog/categories/故障排除/Docker-容器日志清理/" itemprop="url" rel="index"><span itemprop="name">Docker 容器日志清理</span></a></span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>redis服务不可用，可能是磁盘和cpu问题导致，端口和服务是正常的，但是访问不了</p>
<a id="more"></a>
<h1 id="Docker-容器日志清理"><a href="#Docker-容器日志清理" class="headerlink" title="Docker 容器日志清理"></a>Docker 容器日志清理</h1><h4 id="1-检查磁盘空间"><a href="#1-检查磁盘空间" class="headerlink" title="1. 检查磁盘空间"></a>1. 检查磁盘空间</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">[root@izuf6iuxhvb38m9dsv93xlz ~]# df -Th</span><br><span class="line">Filesystem     Type      Size  Used Avail Use% Mounted on</span><br><span class="line">/dev/vda1      ext4       40G   34G  3.9G  100% /</span><br><span class="line">devtmpfs       devtmpfs  3.7G     0  3.7G   0% /dev</span><br><span class="line">tmpfs          tmpfs     3.7G     0  3.7G   0% /dev/shm</span><br><span class="line">tmpfs          tmpfs     3.7G  1.2M  3.7G   1% /run</span><br><span class="line">tmpfs          tmpfs     3.7G     0  3.7G   0% /sys/fs/cgroup</span><br><span class="line">tmpfs          tmpfs     756M     0  756M   0% /run/user/0</span><br><span class="line">tmpfs          tmpfs     756M     0  756M   0% /run/user/1000</span><br><span class="line">overlay        overlay    40G   34G  3.9G  100% /var/lib/docker/overlay2/a7b3d67b195022231b9e06caa0d7583f4d49cc61dca13d5f87b4a257208c32fd/merged</span><br><span class="line">shm            tmpfs      64M     0   64M   0% /var/lib/docker/containers/4b9781b30b644616fc0697bf4b17a770b6885c6dadfc371a2c4776ec8f9e355e/shm</span><br><span class="line">overlay        overlay    40G   34G  3.9G  90% /var/lib/docker/overlay2/2716c7de6afb682bf2f0db4ba6455293e135f0c9b0cce87480f26c60d51c9b52/merged</span><br><span class="line">shm            tmpfs      64M     0   64M   0% /var/lib/docker/containers/cd8985f4e433c132f4b933578a0d497ec44e205464a49232b29175ef5235c977/shm</span><br></pre></td></tr></table></figure>
<blockquote>
<p>从日志查看，磁盘占满100%，需要清理Docker容器日志</p>
</blockquote>
<h4 id="2-清理未使用的镜像和容器"><a href="#2-清理未使用的镜像和容器" class="headerlink" title="2. 清理未使用的镜像和容器"></a>2. 清理未使用的镜像和容器</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker system prune -a</span><br></pre></td></tr></table></figure>
<h4 id="3-清理Docker日志"><a href="#3-清理Docker日志" class="headerlink" title="3. 清理Docker日志"></a>3. 清理Docker日志</h4><h5 id="3-1-检查当前的日志驱动"><a href="#3-1-检查当前的日志驱动" class="headerlink" title="3.1 检查当前的日志驱动"></a>3.1 <strong>检查当前的日志驱动</strong></h5><blockquote>
<p> 通过运行以下命令来查看 Docker 的配置，包括当前的日志驱动：</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker info | grep <span class="string">"Logging Driver"</span></span><br></pre></td></tr></table></figure>
<blockquote>
<p>执行后结果如下：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&gt; [root@izuf6iuxhvb38m9dsv93xlz docker]# docker info | grep &quot;Logging Driver&quot;</span><br><span class="line">&gt;   WARNING: You&apos;re not using the default seccomp profile</span><br><span class="line">&gt; Logging Driver: journald</span><br><span class="line">&gt; WARNING: bridge-nf-call-iptables is disabled</span><br><span class="line">&gt; WARNING: bridge-nf-call-ip6tables is disabled</span><br><span class="line">&gt;</span><br></pre></td></tr></table></figure>
</blockquote>
<blockquote>
<ul>
<li>Docker 当前使用的日志驱动是 <code>journald</code>。这意味着容器的日志并不是存储在传统的文件中，而是通过系统日志服务（<code>systemd-journald</code>）进行管理。</li>
</ul>
</blockquote>
<h5 id="3-2-查看-Docker-日志"><a href="#3-2-查看-Docker-日志" class="headerlink" title="3.2 查看 Docker 日志"></a>3.2 查看 Docker 日志</h5><p>使用 <code>journalctl</code> 命令查看 Docker 的日志。以下命令会显示 Docker 服务的所有日志：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">journalctl -u docker.service</span><br></pre></td></tr></table></figure>
<blockquote>
<p><strong>清理 <code>journald</code> 日志</strong></p>
</blockquote>
<p><code>journald</code> 会保留日志文件以供后续查看，如果这些日志占用了大量空间，通过以下步骤进行清理：</p>
<h5 id="3-3-限制-journald-日志的大小"><a href="#3-3-限制-journald-日志的大小" class="headerlink" title="3.3 限制 journald 日志的大小"></a>3.3 <strong>限制 <code>journald</code> 日志的大小</strong></h5><p>在 <code>/etc/systemd/journald.conf</code> 文件中设置日志大小限制。添加或修改以下行：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">[Journal]</span><br><span class="line">SystemMaxUse=100M</span><br><span class="line">SystemKeepFree=100M</span><br><span class="line">SystemMaxFileSize=10M</span><br></pre></td></tr></table></figure>
<p>这些设置用于限制 <code>journald</code> 使用的总空间和单个日志文件的大小。</p>
<blockquote>
<p>配置项详解</p>
</blockquote>
<ol>
<li><strong><code>SystemMaxUse=100M</code></strong><ul>
<li><strong>含义</strong>：设置 <code>journald</code> 可以使用的最大存储空间为 100 MB。这意味着在达到此限制时，<code>journald</code> 会开始删除旧日志，以确保新日志能够继续写入。</li>
</ul>
</li>
<li><strong><code>SystemKeepFree=100M</code></strong><ul>
<li><strong>含义</strong>：确保系统始终保持至少 100 MB 的可用空间。<code>journald</code> 会根据需要删除旧的日志条目，以满足这个要求。</li>
</ul>
</li>
<li><strong><code>SystemMaxFileSize=10M</code></strong><ul>
<li><strong>含义</strong>：设置单个日志文件的最大大小为 10 MB。当某个日志文件达到此大小时，<code>journald</code> 会轮换日志，即创建一个新的日志文件，并将旧日志文件归档。</li>
</ul>
</li>
</ol>
<blockquote>
<p>重启 <code>systemd-journald</code> 服务</p>
</blockquote>
<ol>
<li><strong>修改配置文件</strong></li>
</ol>
<p>在编辑 <code>/etc/systemd/journald.conf</code> 文件并进行所需的更改后，保存文件。</p>
<ol start="2">
<li><strong>重启 <code>systemd-journald</code> 服务</strong></li>
</ol>
<p>使用以下命令重启 <code>systemd-journald</code> 服务：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl restart systemd-journald</span><br></pre></td></tr></table></figure>
<ol start="3">
<li><strong>确认更改生效</strong></li>
</ol>
<p>使用以下命令检查 <code>systemd-journald</code> 的状态，确认服务是否已成功重启：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl status systemd-journald</span><br></pre></td></tr></table></figure>
<ol start="4">
<li><strong>检查日志配置</strong></li>
</ol>
<p>如果需要验证新配置是否生效，查看日志并确认其行为。例如，使用以下命令查看当前日志的状态：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">journalctl --disk-usage <span class="comment"># 查看当前日志的状态</span></span><br><span class="line">[root@izuf6iuxhvb38m9dsv93xlz docker]<span class="comment"># journalctl --disk-usage</span></span><br><span class="line">Archived and active journals take up 24.0M on disk. <span class="comment"># 这表示系统中所有的 systemd 日志（包括活动日志和归档日志）总共占用了 24.0 MB 的磁盘空间。</span></span><br></pre></td></tr></table></figure>
<h5 id="3-4-清理旧的日志条目"><a href="#3-4-清理旧的日志条目" class="headerlink" title="3.4 清理旧的日志条目"></a>3.4 <strong>清理旧的日志条目</strong></h5><p>使用以下命令手动清理旧的日志：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">journalctl --vacuum-time=2d <span class="comment"># 这将删除超过 2天的日志。可以根据需要调整时间。</span></span><br></pre></td></tr></table></figure>
<blockquote>
<p>使用 <code>journald</code> 作为日志驱动时，管理日志的方式与传统的文件系统有所不同。如果需要清理空间，通过调整 <code>journald</code> 的配置、查看 Docker 的日志。</p>
</blockquote>
<h4 id="4-配置-Docker-使用-json-file-日志驱动（可选）"><a href="#4-配置-Docker-使用-json-file-日志驱动（可选）" class="headerlink" title="4. 配置 Docker 使用 json-file 日志驱动（可选）"></a>4. 配置 Docker 使用 <code>json-file</code> 日志驱动（可选）</h4><ol>
<li>将 Docker 的日志驱动更改为 <code>json-file</code>，以便更方便地管理日志，在 <code>/etc/docker/daemon.json</code> 中添加或修改以下内容：</li>
</ol>
<blockquote>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&gt; &#123;</span><br><span class="line">&gt;   "log-driver": "json-file",</span><br><span class="line">&gt;   "log-opts": &#123;</span><br><span class="line">&gt;     "max-size": "10m",</span><br><span class="line">&gt;     "max-file": "3"</span><br><span class="line">&gt;   &#125;</span><br><span class="line">&gt; &#125;</span><br><span class="line">&gt;</span><br></pre></td></tr></table></figure>
</blockquote>
<ol start="2">
<li>重启Docker容器</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl restart docker</span><br></pre></td></tr></table></figure>
<blockquote>
<p>切换到 <code>json-file</code> 日志驱动后，现有容器的日志设置不会自动更改，需要重新创建这些容器以应用新的日志配置。</p>
</blockquote>

      
    </div>

    

    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/blog/tags/故障排除/" rel="tag"># 故障排除</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2023/03/25/blog/page-statics/page-statics/" rel="next" title="页面静态化技术">
                <i class="fa fa-chevron-left"></i> 页面静态化技术
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


  </div>


          </div>
          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">对美好事物的向往，心中要充满强烈的愿望！</p>
              <p class="site-description motion-element" itemprop="description">沉淀下来的知识，才是真正的财富！</p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/blog/archives/">
                
                    <span class="site-state-item-count">19</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/blog/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">22</span>
                    <span class="site-state-item-name">分类</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/blog/tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">19</span>
                    <span class="site-state-item-name">标签</span>
                  </a>
                </div>
              
            </nav>
          

          

          

          
          

          
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#Docker-容器日志清理"><span class="nav-number">1.</span> <span class="nav-text">Docker 容器日志清理</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-检查磁盘空间"><span class="nav-number">1.0.0.1.</span> <span class="nav-text">1. 检查磁盘空间</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-清理未使用的镜像和容器"><span class="nav-number">1.0.0.2.</span> <span class="nav-text">2. 清理未使用的镜像和容器</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-清理Docker日志"><span class="nav-number">1.0.0.3.</span> <span class="nav-text">3. 清理Docker日志</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#3-1-检查当前的日志驱动"><span class="nav-number">1.0.0.3.1.</span> <span class="nav-text">3.1 检查当前的日志驱动</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#3-2-查看-Docker-日志"><span class="nav-number">1.0.0.3.2.</span> <span class="nav-text">3.2 查看 Docker 日志</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#3-3-限制-journald-日志的大小"><span class="nav-number">1.0.0.3.3.</span> <span class="nav-text">3.3 限制 journald 日志的大小</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#3-4-清理旧的日志条目"><span class="nav-number">1.0.0.3.4.</span> <span class="nav-text">3.4 清理旧的日志条目</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4-配置-Docker-使用-json-file-日志驱动（可选）"><span class="nav-number">1.0.0.4.</span> <span class="nav-text">4. 配置 Docker 使用 json-file 日志驱动（可选）</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright"> &copy; <span itemprop="copyrightYear">2024</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">对美好事物的向往，心中要充满强烈的愿望！</span>

  

  
</div>




  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动 v3.9.0</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 – <a class="theme-link" target="_blank" href="https://theme-next.org">NexT.Gemini</a> v6.4.2</div>




        








        
        <div>
          <a href="https://beian.miit.gov.cn/" target="_blank">闽ICP备15015722号-2</a>
        </div>
      </div>
     
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    
	
    

    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=6.4.2"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=6.4.2"></script>



  
  


  <script type="text/javascript" src="/blog/js/src/affix.js?v=6.4.2"></script>

  <script type="text/javascript" src="/blog/js/src/schemes/pisces.js?v=6.4.2"></script>



  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=6.4.2"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=6.4.2"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=6.4.2"></script>



  



  










  





  

  

  

  

  

  
  

  

  

  

  

  

</body>
</html>
